/*
 * This is the Chat Controller 
 */

package ctrlr;

import gui.ChatCtrlr2GUI;
import java.nio.file.Path;
import java.util.ArrayList;
import ni.ChatCtrlr2NI;

public class ChatCtrlr implements ChatNI2Ctrlr, ChatGUI2Ctrlr {

    private ChatCtrlr2GUI gui;
    private ChatCtrlr2NI ni;
    
    private static boolean fileProposalUdp = true;

    public ChatCtrlr() {  
    }
    
    public void setGui(ChatCtrlr2GUI gui) {
        this.gui = gui;
    }
    
    public void setNi(ChatCtrlr2NI ni) {
        this.ni = ni;
    }

    @Override
    public boolean processFileProposal(String fileName, long fileSize, String from, ArrayList<String> to) {
        return gui.promptTransferPermission(fileName, fileSize, from, to);
    }


    @Override
    public void performConnect(String username) {
        ni.sendHello();
    }

    @Override
    public void performDisconnect(String username) {
        ni.sendGoodbye();
    }

    @Override
    public void performSendTextMessage(String message, ArrayList<String> to) {
        ni.sendTextMessage(message, to);
    }

    @Override
    public void performSendFileProposal(Path filePath, ArrayList<String> to) {
        ni.sendFileProposal(filePath, to);
    }

    @Override
    public void processAcceptFileProposal(String filename, long fileSize, String remoteNetname, ArrayList<String> to) {
        ni.sendFileTransferAccepted(filename, fileSize, remoteNetname, to);
     }

    @Override
    public void processRefuseFileProposal(String filename, long fileSize, String remoteNetname, ArrayList<String> to) {
      ni.sendFileTransferNotAccepted(filename, fileSize, remoteNetname, to);
    }
}
